﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Bll;
using EZCRS.HCMS.Bll.baseinfo;

namespace EZCRS.HCMS.Web.manage.hotel
{
    public partial class receiveInfoadd : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.BasHotelId == 0)
                Response.Write(CFun.AlertMeg(Resources.Site.MustHotel, "back", ""));

            if (!Page.IsPostBack)
            {
                CFun.SetListControl(cbltype, Bllbase_info.getbaseinfo(baseinfotype.消息发送类型, CFun.CurrentLanguage()), "");
                CFun.SetListControl(ddlway, Bllbase_info.getbaseinfo(baseinfotype.消息接收方式, CFun.CurrentLanguage()), "");
                CFun.AddListItems(rblavaliable, EZCRS.HCMS.DataAcl.Common.BoolStatus(), true);
                CFun.SetListControl(cblweeks, HotelBaseInfo.Weebly(), "");

                btnsave.Text = Resources.Site.ButtonSave;

                int id=CFun.RequestNumber("id");
                HCRS_ReceiveInfo _info = new Bllh_receiveinfo().getitem(id);
                if (_info != null)
                {
                    CFun.bindpagedata<HCRS_ReceiveInfo>(this, _info);
                    if (_info.type != "") CFun.SetMultiList(cbltype, _info.type);
                    if (_info.weeks != "") CFun.SetMultiList(cblweeks, _info.weeks);

                    btnsave.Text = Resources.Site.ButtonModify;
                    btndel.Visible = true;
                    btndel.Attributes.Add("onclick", "return confirm('" + Resources.Site.SystemConfirmDelete + "');");
                }

                txtstarttime.Attributes.Add("onclick", "event.cancelBubble=true;showCalendarTA('txtstarttime',false,'txtstarttime','txtstarttime',null);");
                txtstarttime.Attributes.Add("onblur", "if(!chkdate(this.value))this.value='yyyy-MM-dd';");

                txtendtime.Attributes.Add("onclick", "event.cancelBubble=true;showCalendarTA('txtendtime',false,'txtendtime','txtendtime',null);");
                txtendtime.Attributes.Add("onblur", "if(!chkdate(this.value))this.value='yyyy-MM-dd';");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            HCRS_ReceiveInfo _info = new HCRS_ReceiveInfo();
            CFun.getpagedata<HCRS_ReceiveInfo>(_info, this);
            _info.pid = base.BasPropertyId;
            _info.type = CFun.GetMultiList(cbltype);
            _info.weeks = CFun.GetMultiList(cblweeks);

            if(new Bllh_receiveinfo().insertorupdateitem(_info))
                Page.ClientScript.RegisterClientScriptBlock(typeof(String), "scuress", CFun.AlertMeg(Resources.Site.SystemModifySuccess, "", "receiveinfo.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
        }

        protected void btndel_Click(object sender, EventArgs e)
        {
            if(new Bllh_receiveinfo().deleteitem(Convert.ToInt32(hidid.Value)))
                Response.Write(CFun.AlertMeg(Resources.Site.SystemDeleteSuccess, "", "receiveinfo.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
        }
    }
}
